<?php

declare(strict_types=1);

namespace app\admin\controller;

use app\admin\service\interface\CategoryService;


class Category
{
    /**
     * @var CategoryService
     */
    private $categoryService;
    public function __construct(CategoryService $categoryService) {
        $this->categoryService = $categoryService;
    }
    public function add()
    {
        # code...
        try {
            $this->categoryService->add("eeeee");
            return "ok!";
        } catch (\Throwable $th) {
            //throw $th;
            return $th->getMessage();
        }
       
    }
    public function edit() 
    {
        # code...
        try {
            $res = $this->categoryService->edit(1, "ffff");
            if ($res) {
                return "ok!";
            }
            throw new \Exception("Error Processing Request", 1);
            
        } catch (\Throwable $th) {
            //throw $th;
            return $th->getMessage();
        }
    }
}
